<script setup lang="ts">
const {data, error, pending} = await useFetch('/api/hello')

const result = ref("")

async function click() {
  const {data, error, pending} = await useFetch('/api/click')
  result.value = data.value as string
}
</script>

<template>
  <div>
    <h1>Home</h1>

    <div v-if="pending">加载中...</div>
    <div v-else-if="error">请求失败: {{ error.message }}</div>
    <div v-else>返回数据: {{ data }}</div>

    <button @click="click">页面加载后的按钮</button>
    <h1>{{ result }}</h1>

  </div>
</template>

